<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="BaseTable">

    <div class="layui-card-body padding-left-40">

        <fieldset class="layui-bg-gray">
            <legend><b class="layui-badge think-bg-violet">正品数据</b></legend>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-xs4">
                    <label class="relative block">
                        <span class="help-label"><b>桶数</b>每件420斤</span>
                        <input name="box_num" value='{$vo.box_num|default=""}' 
                            placeholder="请输入" class="layui-input">
                    </label>
                </div>
                <div class="layui-col-xs4">
                    <label class="relative block">
                        <span class="help-label"><b>散件重量</b></span>
                        <input class="layui-input" name="bulk_weight" value='{$vo.bulk_weight|default=""}' placeholder="请输入">
                    </label>
                </div>
                <div class="layui-col-xs4">
                    <label class="relative block">
                        <span class="help-label"><b>总重量</b></span>
                        <input class="layui-input" name="total_weight" disabled="true" value='{$vo.total_weight|default=""}' placeholder="请输入">
                    </label>
                </div>
            </div>
            
        </fieldset>
        <fieldset class="layui-bg-gray">
            <legend><b class="layui-badge think-bg-violet">次品数据</b></legend>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-xs4">
                    <label class="relative block">
                        <span class="help-label"><b>桶数</b></span>
                        <input name="other_box_num" value='{$vo.other_box_num|default=""}' placeholder="请输入" class="layui-input">
                    </label>
                </div>
               
                <div class="layui-col-xs4">
                    <label class="relative block">
                        <span class="help-label"><b>总重量</b></span>
                        <input class="layui-input" name="other_total_weight" value='{$vo.other_total_weight|default=""}'
                            placeholder="请输入">
                    </label>
                </div>
            </div>
        
        </fieldset>

        

        <label class="layui-form-item relative block layui-col-xs4">
            <span class="help-label"><b>日期</b></span>
            <input data-date-input name="create_date" value="{$vo.create_date|default=''}" placeholder="{:lang('请选择创建时间')}"
                class="layui-input">
        </label>

        <label class="layui-form-item relative block">
            <span class="help-label"><b>备注</b></span>
            <textarea name="remark" class="layui-textarea" placeholder="请输入备注">{$vo.remark|default=''}</textarea>
        </label>

    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

</form>

<script>
    layui.use(['form', 'jquery','laydate'], function () {
        var form = layui.form, $ = layui.$;

        var laydate = layui.laydate;

        //常规用法
          // 渲染日期选择器
        laydate.render({
            elem: '#test1',          // 绑定元素
            type: 'date',            // 日期类型
            format: 'yyyy-MM-dd',    // 日期格式
            value: new Date(),       // 设置默认值为当前日期
            trigger: 'click'         // 触发方式
        });


        // 实时计算总重量
        function calculateTotal() {
            var pieces = parseInt($('input[name="box_num"]').val()) || 0;
            var bulk = parseFloat($('input[name="bulk_weight"]').val()) || 0;
            var total = (pieces * 420) + bulk;
            $('input[name="total_weight"]').val(total.toFixed(2) + ' 斤');
        }

        // 绑定事件
        $('input[name="box_num"], input[name="bulk_weight"]').on('input', function () {
            calculateTotal();
        });

        // 初始化计算
        calculateTotal();
    });
</script>